package demo6;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Demo {
    public  static void menu(){
        System.out.println("欢迎来到员工信息管理系统！");
        System.out.println("0.退出系统");
        System.out.println("1.添加员工");
        System.out.println("2.查询所有员工");
        System.out.println("3.根据员工姓名查找员工信息");
        System.out.println("4.删除员工工号");
        System.out.println("5.根据员工编号查找");
        System.out.println("6.根据员工编号修改年龄");
        System.out.println("请选择需要进行的操作");
    }

    public static void main(String[] args) {
        TestList testList=new TestList();
        List<Emp> list=new ArrayList<>();
        Emp emp=new Emp();
        boolean flag=true;
        while(flag){
            System.out.println("欢迎来到员工信息管理系统！");
            System.out.println("0.退出系统");
            System.out.println("1.添加员工");
            System.out.println("2.查询所有员工");
            System.out.println("3.根据员工姓名查找员工信息");
            System.out.println("4.删除员工工号");
            System.out.println("5.根据员工编号查找员工信息");
            System.out.println("6.根据员工编号修改年龄");
            System.out.println("请选择需要进行的操作:");
            Scanner scanner=new Scanner(System.in);
            int n= scanner.nextInt();
            switch(n){
                case 0:
                    System.out.println("退出系统");
                    flag=false;
                    break;
                case 1:
                    System.out.println("添加员工");
                    System.out.println("添加编号");
                    String addNum= scanner.next();
                    System.out.println("添加姓名");
                    String addName= scanner.next();
                    System.out.println("添加年龄");
                    int addAge= scanner.nextInt();
                    emp.setNum(addNum);
                    emp.setName(addName);
                    emp.setAge(addAge);
                    Emp addEmp=new Emp(addNum,addName,addAge);
                    testList.addEmp(list,emp);
                    System.out.println(list);
                case 2:
                    System.out.println("查询所有员工");
                    testList.findAllEmp(list);
                    break;
                case 3:
                    System.out.println("根据员工姓名查找员工信息");
                    System.out.println("输入需要查找的员工姓名");
                    String empName = scanner.next();
                    testList.findEmpName(list,empName);
                    System.out.println(emp);
                    break;
                case 4:
                    System.out.println("删除员工工号");
                    System.out.println("输入需要删除员工工号");
                    String empNum = scanner.next();
                    testList.findEmpName(list,empNum);
                    testList.deleteEmpNum(list,empNum);
                    System.out.println(list);
                    break;
                case 5:
                    System.out.println("根据员工编号查找员工信息");
                    System.out.println("输入需要查找的员工编号");
                    String empNumb = scanner.next();
                    testList.findEmpNum(list,empNumb);
                    System.out.println(emp);
                    break;
                case 6:
                    System.out.println("根据员工编号修改年龄");
                    System.out.println("输入需要查找的员工编号");
                    String empNumber = scanner.next();
                    System.out.println("输入需要修改年龄");
                    int updateAge= scanner.nextInt();
                    testList.findEmpNum(list,empNumber);
                    emp.setAge(updateAge);
                    testList.updateEmpAge(list,emp);
                    System.out.println(list);
                    break;
            }
        }
    }
}
